<?
	if (!checkReg() OR !checkPrivAdmin()) {
		header("Location: /login/");
		exit;
	}


	if (count($_POST)) {
		$handle  = fopen($ROOT."/".$FOLDER."/vars.0.pages.php", "w+");
 		fwrite($handle, "<?\n");
			
			reset($_POST[PAGES]);
			for($i=0; $i != count($_POST[PAGES]); $i++) {
	
				if (fill($_POST[PAGES][$i])) {
			 		fwrite($handle, "\t");

					fwrite($handle, "\$PAGES[]=\"".clearString($_POST[PAGES][$i])."\";     \t\t");
					fwrite($handle, "\$MENU[]=\"".clearString($_POST[MENU][$i])."\";     \t\t");
					fwrite($handle, "\$TEMPLATES[]=\"".clearString($_POST[TEMPLATES][$i])."\";   \t\t");
					fwrite($handle, "\$NAME[]=\"".clearString($_POST[NAME][$i])."\";     \t\t");
					fwrite($handle, "\$HEADER[]=\"".clearString($_POST[HEADER][$i])."\"; ");

			 		fwrite($handle, "\n");
				}
			}


	 		fwrite($handle, "?>\n");
		fclose($handle);

		Header("Location: http://".getenv("SERVER_NAME")."/insky/pages/");
		exit();

	}


?>
